/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tsb.UI.PanelArrastrar;

import java.awt.*;
import java.awt.geom.Line2D;


public class LineaConexion {
    
   
    public static final int ethernetRJ45=1;
    public static final int fibra=2;
    public static final int serialDCE=3;
    public static final int ethernetRJ11=4;
    public static final int wireless=5;
    public static final int coaxial=6;
    public static final int automatica=7;
    public static final int serialDTE=8;
    
    private Point ini, fin;
    private int tipo;
    
   private BotonPersonalizado botonInicio;
   private BotonPersonalizado botonFin;
   
   private String nombreAMostrar="";
           
    
    public LineaConexion(int tipo, Point ini, Point fin,BotonPersonalizado bIni) {
        this.tipo=tipo;
        this.ini=ini;
        this.fin=fin;
        botonInicio=bIni;
    }
    
    public void setBotonFin(BotonPersonalizado bFin)
    {
        this.botonFin=bFin;
    }
    
    public BotonPersonalizado getBotonFin()
    {
        return this.botonFin;
    }
    
    public BotonPersonalizado getBotonInicio()
    {
        return this.botonInicio;
    }

    public String getNombreAMostrar() {
        return nombreAMostrar;
    }

    public void setNombreAMostrar(String nombreAMostrar) {
        this.nombreAMostrar = nombreAMostrar;
    }
    

    public Point getFin() {
        return fin;
    }

    public void setFin(Point fin) {
        this.fin = fin;
    }

    public int getTipo(){
        return tipo;
    }
    public Point getIni() {
        return ini;
    }

    public void setIni(Point ini) {
        this.ini = ini;
    }
    
    
    //mientras sedibuja la figura
    public void dibujar(Graphics g, Point ini, Point fin){
        this.ini=ini;
        this.fin=fin;
        Graphics2D g2d = ( Graphics2D ) g;
       
        
        switch(tipo)
        {
            case 1: 
                g2d.setPaint( new Color(0, 255, 0));//verde
                break;
            case 2:
                g2d.setPaint( new Color(0,0,255));//Azul
                break;
            case 3: 
                g2d.setPaint( new Color(204,0,0));//Bordo
                break;
            case 4:
                g2d.setPaint( new Color(153,153,153));//Gris
                break;
            case 5:
                g2d.setPaint( new Color(255,153,255));//Rosa
                break;
            case 6:
                g2d.setPaint( new Color(0,153,153));//Verde oscuro
                break;
            case 7:
                g2d.setPaint( new Color(204,102,255));//Violeta
                break;
            case 8:
                g2d.setPaint( new Color(255,255,153));//Amarillo
                break;
        }
        
        //g2d.setPaint( this.color);
        float guiones[] = { 1 };
        g2d.setStroke( new BasicStroke( 3, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 5, guiones, 0 ) );
        g2d.draw( new Line2D.Double( ini.x, ini.y, fin.x, fin.y ) );
    }
    
    //figura final
    public void dibujar(Graphics g){
        dibujar(g, ini, fin);
    }

    public void borrar(Graphics g)
    {
        (( Graphics2D )g).clearRect(ini.x, ini.y, fin.x, fin.y);
    }
}

